package com.ryskoo.customer.customerintegral.repository;

import com.ryskoo.customer.customerintegral.domain.CustomerIntegralPO;
import com.ryskoo.framework.core.bean.QueryConditionEnum;
import com.ryskoo.framework.core.bean.QueryMessageDTO;
import com.ryskoo.framework.core.repository.BasicJPAImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CustomerIntegralJPAImpl extends BasicJPAImpl<CustomerIntegralPO> implements ICustomerIntegralRepository {
    /**
     * 获取会员积分
     *
     * @param customerUuid
     * @param vendorUuid
     * @return
     */
    @Override
    public CustomerIntegralPO getIntegral(String customerUuid, String vendorUuid) {
        QueryMessageDTO qm = new QueryMessageDTO();
        qm.addCondition("customerUuid", QueryConditionEnum.EQ.name(), customerUuid);
        qm.addCondition("vendorUuid", QueryConditionEnum.EQ.name(), vendorUuid);
        List<CustomerIntegralPO> list = queryByCondition(qm, false);
        if(CollectionUtils.isNotEmpty(list)){
            return list.get(0);
        }
        return null;
    }
}
